package com.gton.lpl.common.pojo;

import java.time.LocalDateTime;

/**
 * @description: 加密与解密
 * @author: GuoTong
 * @createTime: 2021-10-30 19:15
 * @since JDK 1.8 OR 11
 **/

public class CodeSignUtil {

    private static String[] codeUse = {"g", "u", "o", "t", "o", "n", "g"};

    //每天生成不同的加密签名
    public static String randomByDayKeys() {
        LocalDateTime now = LocalDateTime.now();
        int dayOfMonth = now.getDayOfMonth();
        //取模运算:组成keys的首位
        int j = dayOfMonth % 7;
        //取出当前这天是这个月的第几天，不满两位数补零
        String builder = codeUse[j] +
                (dayOfMonth < 10 ? "0" : "") +
                dayOfMonth +
                "$" +
                now.getDayOfYear();
        return builder;
    }

    public static void main(String[] args) {
        System.out.println(randomByDayKeys());
    }
}
